from frb_pipeline_tools import *
import os

# ======= 📝 手动填写以下参数 ========
fits_path = "/Users/zhang/Downloads/data/FRB20201124A_tracking-M01_0001.fits"
sample_id = 8000
DM = 1200
SNR = 13.2

# ========== 自动提取相关参数 ==========
fits_dir = os.path.dirname(fits_path)
fits_list = [fits_path]
fits_name = os.path.basename(fits_path)
fits_index = 0  # 只有一个文件，索引为 0

# 提取数据段
data, freqs, times, tsamp, mjd_start = extract_candidate_segment(
    fits_list, fits_index, sample_id, DM
)

# 数据处理
data_clean = normalise(data)
data_dedisp = dedisperse(data_clean, freqs, tsamp, DM)

# 显示四图（不保存）
plot_frb_four_panel_summary(
    data_raw=data_clean,
    data_dedispersed=data_dedisp,
    freqs=freqs,
    times=times,
    tsamp=tsamp,
    snr=SNR,
    dm=DM,
    sample_id=sample_id,
    fits_file=fits_path,
    mjd_start=mjd_start,
    line_number=1,           # 手动测试就写 1
    outname=None             # 不保存，只显示
)